package com.feiyun.api.qd;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.feiyun.mapper.UserFileRelationMapper;
import com.feiyun.mapper.UserMapper;
import com.feiyun.model.entity.User;
import com.feiyun.model.entity.UserFileRelation;
import com.feiyun.service.ITempUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import javax.validation.constraints.PositiveOrZero;
import java.util.List;

@Controller
@Slf4j
public class PageController {

    @Resource
    private UserMapper userMapper;
    @Resource
    private ITempUserService iTempUserService;

    @GetMapping("/index")
    public String myTemplate() {
        return "index";
    }

    @GetMapping("/upload")
    public String upload() {
        return "upload";
    }

    @GetMapping("/uploadUser/{id}")
    public String uploadUser(@PathVariable @PositiveOrZero String id, Model model){
        log.info("跳转上传信息页面，接受参数id：{}",id);
        model.addAttribute("uploadRecordId",id);
        return "uploadUser";
    }
    @GetMapping("/updateUserInfo/{id}")
    public String updateUserInfo(@PathVariable @PositiveOrZero String id, Model model){
        model.addAttribute("userUUid",id);
        User user = userMapper.selectById(id);
        model.addAttribute("customer",user);

        model.addAttribute("fileId",iTempUserService.findFileIdByUploadUser(id));
        return "updateUserInfo";
    }
    @GetMapping("/uploadImage/{id}")
    public String updateImage(@PathVariable @PositiveOrZero String id, Model model){
        model.addAttribute("userId",id);
        User user = userMapper.selectById(id);
        model.addAttribute("customer",user);
        model.addAttribute("fileId",iTempUserService.findFileIdByUploadUser(id));
        return "uploadImage";
    }

    @GetMapping("/uploadHeadImage/{id}")
    public String uploadHeadImage(@PathVariable @PositiveOrZero String id, Model model){
        model.addAttribute("userId",id);
        User user = userMapper.selectById(id);
        model.addAttribute("customer",user);
        model.addAttribute("fileId",iTempUserService.findFileIdByUploadUser(id));
        return "uploadHeadImage";
    }
    @GetMapping("/userList/{pageId}")
    public String userList(@PathVariable @PositiveOrZero int pageId,Model model){
        //id 当前页
        model.addAttribute("pageId",pageId);
        return "userList";
    }
}
